#ifndef TOYDIALOG_H
#define TOYDIALOG_H

#include <QDialog>
#include <QFormLayout>
#include <QLineEdit>
#include <QDoubleSpinBox>
#include <QPushButton>
#include <QDialogButtonBox>
#include <QLabel>
#include <QListWidget>
#include <QCheckBox>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QSqlQuery>
#include <QMessageBox>
#include <QMap>

class ToyDialog : public QDialog
{
    Q_OBJECT

public:
    explicit ToyDialog(QWidget *parent = nullptr);
    
    // 设置和获取玩具信息
    void setToyData(const QString &toyId, const QString &name, 
                   const QString &description, const QList<int> &processIds);
    
    QString getToyId() const;
    QString getName() const;
    QString getDescription() const;
    QList<int> getSelectedProcessIds() const;
    
    // 设置编辑模式（玩具编号不可编辑）
    void setEditMode(bool editMode);

private slots:
    void validateInput();
    void onProcessSelectionChanged();

private:
    void setupUI();
    void loadProcesses();
    void updateProcessSelection(const QList<int> &processIds);
    
    QLineEdit *m_toyIdEdit;
    QLineEdit *m_nameEdit;
    QLineEdit *m_descriptionEdit;
    QListWidget *m_processListWidget;
    QLabel *m_selectedProcessesLabel;
    QDialogButtonBox *m_buttonBox;
    
    bool m_isEditMode;
    QMap<int, QString> m_processMap; // processId -> processName
};

#endif // TOYDIALOG_H